#ifndef __LINK_H
#define __LINK_H
#include <stdint.h>
#include "riselib/mempool.h"

#ifdef __cplusplus
extern "C" {
#endif

typedef enum {
  linkType_serial = 0x10,
  linkType_usart = 0x11,
  linkType_tty = 0x12,
  linkType_udp = 0x20,
  linkType_tcp = 0x21,
  linkType_http = 0x30,
  linkType_websocket = 0x31,
} LinkTypeEnum;
typedef enum {
  linkStatus_temp = 0x00,
  linkStatus_fixed = 0x80,
  linkStatus_client = 0x90,
  linkStatus_server = 0xA0,
} LinkStatusEnum;

typedef struct LinkCfg {
  LinkTypeEnum type;
  LinkStatusEnum status;
  uint8_t* address;
  uint32_t port;
  void* fd;
  void (*send)(uint8_t* data, uint16_t dataLen, struct LinkCfg*);
  void (*recv)(uint8_t*, uint16_t, struct LinkCfg*);
} LinkCfgStruct;  //底层连接配置结构

LinkCfgStruct* link_new(LinkCfgStruct* src);
void link_del(LinkCfgStruct* self);

#ifdef __cplusplus
}
#endif
#endif  //__LINK_H
